<?php
class IndexSection extends CWidget {
	public $posts = array();
	
	public function __construct() {
		if( ! isAjax()) {
			exit;
		}
	}
	public function init() {
		$categoryId = $_POST['categoryId'];
		$this->posts['meta'] = TermsTaxonomy::model()->findByPk($categoryId);
		$this->posts['rows'] = Posts::model()->section()->findByCategoryId($categoryId);
	}
	
	public function run() {
		$this->renderContent();
	}
	
	public function renderContent() {
		$this->render('indexSection', array(
				'posts' => $this->posts,
				'sectionSize' => 10
			)
		);
	}
}